package edu.uwm.capstone.diasmart.database;

import edu.uwm.capstone.util.Identifiable;
import edu.uwm.capstone.util.StringUtil;

public class Category implements Identifiable {

	private long endTime = -1L;
	private long id = -1L;
	private boolean isDefault = false;
	private boolean isUserDefault = false;
	private long lastCategoryId = -1L;
	private boolean modified = false;
	private String name;
	private long startTime = -1L;
	private int userOrder = 0;

	/**
	 * 
	 */
	public Category() {
	}

	/**
	 * @param id
	 * @param name
	 * @param isDefault
	 */
	public Category(long id, String name, boolean isDefault) {
		this(id, name, isDefault, -1L, -1L, 0, -1L, false);
	}

	/**
	 * @param id
	 * @param name
	 * @param isDefault
	 * @param startTime
	 * @param endTime
	 * @param userOrder
	 * @param lastCategoryId
	 * @param isUserDefault
	 */
	public Category(long id, String name, boolean isDefault,
			long startTime, long endTime, int userOrder, long lastCategoryId,
			boolean isUserDefault) {
		this.id = id;
		this.name = name;
		this.isDefault = isDefault;
		this.startTime = startTime;
		this.endTime = endTime;
		this.userOrder = userOrder;
		this.lastCategoryId = lastCategoryId;
		this.isUserDefault = isUserDefault;
	}

	/**
	 * @param name
	 * @param isDefault
	 */
	public Category(String name, boolean isDefault) {
		this(-1L, name, isDefault);
		this.modified = true;
	}

	/**
	 * @return
	 */
	public long getEndTime() {
		return this.endTime;
	}

	/* (non-Javadoc)
	 * @see edu.uwm.capstone.util.Identifiable#getId()
	 */
	public long getId() {
		return this.id;
	}

	/**
	 * @return
	 */
	public long getLastCategoryId() {
		return this.lastCategoryId;
	}

	/**
	 * @return
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * @return
	 */
	public long getStartTime() {
		return this.startTime;
	}

	/**
	 * @return
	 */
	public int getUserOrder() {
		return this.userOrder;
	}

	/**
	 * @return
	 */
	public boolean isDefault() {
		return this.isDefault;
	}

	/**
	 * @return
	 */
	public boolean isModified() {
		return this.modified;
	}

	/**
	 * @return
	 */
	public boolean isUserDefault() {
		return this.isUserDefault;
	}

	/**
	 * @param isDefault
	 */
	public void setDefault(boolean isDefault) {
		if (this.isDefault != isDefault) {
			this.isDefault = isDefault;
			this.modified = true;
		}
	}

	/**
	 * @param endTime
	 */
	public void setEndTime(long endTime) {
		if (this.endTime != endTime) {
			this.endTime = endTime;
			this.modified = true;
		}
	}

	/**
	 * @param id
	 */
	void setId(long id) {
		this.id = id;
	}

	/**
	 * @param lastCategoryId
	 */
	public void setLastCategoryId(long lastCategoryId) {
		if (this.lastCategoryId != lastCategoryId) {
			this.lastCategoryId = lastCategoryId;
			this.modified = true;
		}
	}

	/**
	 * @param modified
	 */
	void setModified(boolean modified) {
		this.modified = modified;
	}

	/**
	 * @param name
	 */
	public void setName(String name) {
		if (!StringUtil.isEqual(this.name, name)) {
			this.name = name;
			this.modified = true;
		}
	}

	/**
	 * @param startTime
	 */
	public void setStartTime(long startTime) {
		if (this.startTime != startTime) {
			this.startTime = startTime;
			this.modified = true;
		}
	}

	/**
	 * @param isUserDefault
	 */
	public void setUserDefault(boolean isUserDefault) {
		if (this.isUserDefault != isUserDefault) {
			this.isUserDefault = isUserDefault;
			this.modified = true;
		}
	}

	/**
	 * @param userOrder
	 */
	public void setUserOrder(int userOrder) {
		if (this.userOrder != userOrder) {
			this.userOrder = userOrder;
			this.modified = true;
		}
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return this.name;
	}

}
